
<!DOCTYPE html>
<html lang="zh_CN">
<head>
    <#include "../common/head.ftl">
    <style>
        #ContentModal img{
            width: 100%;
        }
        #ContentModal .modal-body{
            overflow-x: auto;
            max-height: 500px;
        }
    </style>
</head>
<body>

<div class="container " style="margin-top: 20px">
    <#include "../common/top.ftl">
    <div class="row">
        <div class="col-sm-3">
            <#--设置当前要回显当前菜单,必须在载人菜单前完成设置-->
            <#assign menu = "newsCommend"/>
            <#include "../common/menu.ftl">
        </div>
        <div class="col-sm-9">
            <div class="row">
                <div class="col-sm-12">
                    <h1 class="page-head-line">推荐资讯</h1>
                </div>
            </div>
            <#--高级查询--->
            <form class="form-inline" id="searchForm" action="/newsCommend/list.do" method="post">
                <input type="hidden" id="currentPage" name="currentPage" value="1">
                <div class="form-group">
                    <label>关键字:</label>
                    <input type="text" class="form-control" name="keyword" value="${(qo.keyword)!}"
                           placeholder="请输入标题">
                </div>
                <button id="btn_query" class="btn btn-info">
                    <span class="glyphicon glyphicon-search"></span> 查询
                </button>
            </form>

            <table class="table table-striped table-hover" >
                <tr>
                    <th>编号</th>
                    <th>标题</th>
                    <th>封面</th>
                    <th>摘要</th>
                    <th>推荐时间</th>
                    <th>操作</th>
                </tr>

                <#list pageInfo.list as t>
                <#--遍历查询得到的每一个domain对象-->
                    <tr>
                        <td>${t_index+1}</td>
                        <td>${(t.title)!}</td>
                        <td><img src="${t.coverUrl!}" width="50px"></td>
                        <td>${(t.summary)!}</td>
                        <td>${(t.schedule)?string("yyyy-MM-dd")!}</td>
                        <td>
                            <a href ="javascript:;" class="changeStateBtn" data-state="0" data-id="${(t.news.id)!}">取消推荐</a>
                            <a href ="javascript:;" class="showContentBtn" data-id="${t.id}">查看内容</a>
                        </td>
                    </tr>
                </#list>

            </table>
            <#include "../common/page.ftl">
        </div>
    </div>
</div>
<#--查看文章-->
<div class="modal fade" id="ContentModal" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">资讯内容</h4>
            </div>
            <div class="modal-body">

            </div>
        </div>
    </div>
</div>

<script>
    $(function () {
        $(".changeStateBtn").click(function () {
            var state = $(this).data("state");
            console.log(state);
            var id = $(this).data("id");
            $.get("/news/changeState.do",{state:state,id:id},function (data) {
                if(data.success){
                    window.location.reload();
                }else{
                    $.messager.alert("温馨提示",data.msg);
                }
            })
        })

        //查看文章
        $(".showContentBtn").click(function () {
            var id = $(this).data("id");
            $.get("/news/getContent.do",{id:id},function(data){
                console.log(data);
                $("#ContentModal .modal-body").html(data.content);
                $("#ContentModal").modal("show");
            })

        })
    })


</script>
</body>
</html>